//
//  CustomButton.m
//  DaFangYa
//
//  Created by design on 15/7/28.
//  Copyright (c) 2015年 HFKJ_LZQ. All rights reserved.
//

#import "CustomButton.h"

@implementation CustomButton
@synthesize selectedTitleColor = _selectedTitleColor;
@synthesize normalTitleColor = _normalTitleColor;
@synthesize imageName_url = _imageName_url;
//@synthesize selected = _selected;

//-(void)awakeFromNib
//{
//    [super awakeFromNib];
//    DLOG(@"进入CustomBuildListDataView awakeFromNib");
//    [self initWithFrame:CGRectMake(0, 0, DeviceWidth, scaleHeight(320, 180/320))];
//}

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _myWidth = frame.size.width;
        _myHeight = frame.size.height;
        _leftImageView = [[UIImageView alloc] init];
        _myTitleLabel = [[UILabel alloc] init];
        _myTitleLabel.textAlignment = NSTextAlignmentCenter;
        _myTitleLabel.font = themeFont12;
        _bottomImageView = [[UIImageView alloc] init];
        [self addSubview:_leftImageView];
        [self addSubview:_myTitleLabel];
        [self addSubview:_bottomImageView];
        _normalTitleColor = kDefaultWhiteColor;
        _selectedTitleColor = kDefaultWhiteColor;
        
    }
    return self;
}
-(void)setButtonSubViews:(CGRect)titleFrame andLeftFrame:(CGRect)leftFrame andBottomFrame:(CGRect)bottomFrame
{
    _myTitleLabel.frame = titleFrame;
    _leftImageView.frame = leftFrame;
    _bottomImageView.frame = bottomFrame;
    [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:_imageName_url]];
    self.myTitleLabel.textColor = _selectedTitleColor;
    self.myTitleLabel.text = _title;
    
}
-(NSString *)imageName_url
{
    return _imageName_url;
}
-(void)setImageName_url:(NSString *)imageName_url
{
    _imageName_url = imageName_url;
    [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:_imageName_url]];
}

-(void)setButtonData:(BOOL)isselected
{
    if (isselected) {
        //选中
        self.myTitleLabel.textColor = _selectedTitleColor;
        self.myTitleLabel.text = _title;
//        self.leftImageView.image = _selectLeftImage;
//        self.bottomImageView.image = _selectBottomImage;
        [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:_imageName_url]];
    }
    else
    {
        //normal 状态
        self.myTitleLabel.textColor = _normalTitleColor;
        self.myTitleLabel.text = _title;
//        self.leftImageView.image = _normalLeftImage;
//        self.bottomImageView.image = _normalBottomImage;
        [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:_imageName_url]];
    }
    
}

-(void)setSelectedTitleColor:(UIColor *)selectedTitleColor
{
    _selectedTitleColor = selectedTitleColor;
    self.myTitleLabel.textColor = _selectedTitleColor;
   
}
-(UIColor *)selectedTitleColor
{
    return self.selectedTitleColor;
}
-(void)setNormalTitleColor:(UIColor *)normalTitleColor
{
    _normalTitleColor = normalTitleColor;
     self.myTitleLabel.textColor = _normalTitleColor;
}
-(UIColor *)normalTitleColor
{
    return self.normalTitleColor;
}
//-(void)setSelected:(BOOL)selected
//{
//    _selected = selected;
//    if (selected) {
//        //选中
//        self.myTitleLabel.textColor = _selectedTitleColor;
//        self.myTitleLabel.text = _title;
////        self.leftImageView.image = _selectLeftImage;
////        self.bottomImageView.image = _selectBottomImage;
//        [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:_imageName_url]];
//        
//    }
//    else
//    {
//        //normal 状态
//        self.myTitleLabel.textColor = _normalTitleColor;
//        self.myTitleLabel.text = _title;
////        self.leftImageView.image = _normalLeftImage;
////        self.bottomImageView.image = _normalBottomImage;
//        [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:_imageName_url]];
//        
//    }
//}


//-(void)setTitle:(NSString *)title forState:(UIControlState)state
//{
//    self.myTitleLabel.text = title;
//}
//-(void)setMyLeftImage:(UIImage *)image forState:(UIControlState)state
//{
//
//}
//-(void)setMyBottomImage:(UIImage *)image forState:(UIControlState)state
//{
//    
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
